import request from '@/utils/request'
import type {Community} from '@/types/community'
import type {Doctor} from '@/types/doctor'
import {Elder} from "../types/elder";
import {Child} from "../types/child";

export interface CommunityQueryParams {
    communityName?: string;  // 社区名称（模糊查询）
    address?: string;      // 地址（模糊查询）
    phone?: string;      // 电话号码（模糊查询）
}

// 获取所有社区
export function getAllCommunities(params?: CommunityQueryParams) {
    return request<Community[]>({
        url: '/community/findAllCommunity',
        method: 'get',
        params
    })
}

// 添加社区
export function addCommunity(data: Community) {
    return request<boolean>({
        url: '/community/addCommunity',
        method: 'post',
        data
    })
}

// 更新社区
export function updateCommunity(data: Community) {
    return request<Community>({
        url: '/community/updateCommunity',
        method: 'post',
        data
    })
}

// 删除社区
export function deleteCommunity(data: { id: number }) {
    return request<boolean>({
        url: '/community/delCommunity',
        method: 'delete',
        data
    })
}

// 获取社区医生列表
export function getCommunityDoctors(communityId: number) {
    return request<Doctor[]>({
        url: '/community/getCommunityDoctor',
        method: 'get',
        params: {communityId}
    })
}


// 获取社区老年人列表
export function getCommunityElders(communityId: number) {
    return request<Elder[]>({
        url: '/community/getCommunityElder',
        method: 'get',
        params: {communityId}
    })
}

// 获取社区儿童列表
export function getCommunityChildren(communityId: number) {
    return request<Child[]>({
        url: '/community/getCommunityChild',
        method: 'get',
        params: {communityId}
    })
} 